package com.simen.hellobytes.log;

import java.text.SimpleDateFormat;
import java.util.logging.FileHandler;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;

/**
 * author: SimenHi
 * create time: 2021-01-04 10:51
 * description:
 */
public class JavaLog {

    private static final Logger logger=Logger.getLogger(JavaLog.class.getName());

    public void test(){
        SimpleDateFormat format = new SimpleDateFormat("M-d_HHmmss");
        FileHandler fh=null;
        try {
            fh = new FileHandler("MyLogFile.log");
            fh.setFormatter(new SimpleFormatter());
            logger.addHandler(fh);

            logger.info("info msg");
            logger.severe("error message");
            logger.fine("fine message");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
